﻿using CommonTools;
using Sunny.UI;

namespace StationDemo
{
    public partial class FLogin : UILoginForm
    {
        public FLogin()
        {
            InitializeComponent();
            this.DialogResult = System.Windows.Forms.DialogResult.No;

        }

        private void FLogin_ButtonLoginClick(object sender, System.EventArgs e)
        {
            //this.ShowInfoTip("admin  admin ");
            //if (UserName == "admin" && Password == "admin")
            //{
            //    IsLogin = true;
            //    Close();
            //}

            foreach (var temp in sys.g_listUser)
            {
                if (UserName == temp._userName)
                {
                    if (temp._userPassWord == Password)
                    {
                        sys.g_User = temp;
                        this.DialogResult = System.Windows.Forms.DialogResult.Yes;
                        this.Close();
                        return;
                    }
                    else
                    {
                        this.ShowErrorDialog("密码错误"); //显示在最顶层
                        //UIMessageBox.ShowError("密码错误");//遇到topmost的窗口不会显示在顶层
                        return;
                    }

                }
            }
         
            this.ShowErrorDialog("没有此用户");
            //this.Close();


        }

        private void FLogin_ButtonCancelClick(object sender, System.EventArgs e)
        {

        }
    }
}